package fem2.level_set;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * represent level set for a discontinuity (crack, inclusion, void, ...)
 * 
 * @author hbui
 * 
 */
public class Discontinuity {

	private Map<String, LevelSet> LSList = new TreeMap<String, LevelSet>();

	public Discontinuity() {
	}

	/**
	 * add the new level set to the discontinuity
	 * 
	 * @param name
	 * @param ls
	 */
	public void addLevelSet(LevelSet ls) {
		if (getLevelSetNames().contains(ls.getName())) {
			throw new Error("the level set " + ls.getName() + " has been existed");
		}
		LSList.put(ls.getName(), ls);
	}

	/**
	 * get the level set
	 * 
	 * @param name
	 * @return
	 */
	public LevelSet getLevelSet(String name) {
		LevelSet ls = LSList.get(name);
		if (ls == null) {
			throw new Error("this discontinuity does not contain level set name " + name);
		}
		return ls;
	}

	/**
	 * 
	 * @return the list of level set names associated with the discontinuity
	 */
	public Set<String> getLevelSetNames() {
		return LSList.keySet();
	}
}
